﻿
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl
Imports storoomc

Public Class homepage
    Inherits cacheControlProcessor

    Public Const _pathidentity As String = "/"

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Protected Overrides Function processImpl(ByVal context As httpContext, ByRef control As xmlcontrol) As Boolean
        assert(Not context Is Nothing, "context is nothing.")

        Dim page As xhtmlpage = Nothing
        page = context.createControl(New xhtmlpage())
        page.title().text = context.string(stringId.HOMEPAGE_TITLE)

        Dim h3 As h3 = Nothing
        h3 = context.createControl(New h3())
        h3.text = context.string(stringId.HOMEPAGE_BRAND)
        page.body().addchild(h3)

        Dim h4 As h4 = Nothing
        h4 = context.createControl(New h4())
        h4.text = context.string(stringId.HOMEPAGE_INTRODUCTION)
        page.body().addchild(h4)

        Dim ul As ul = Nothing
        ul = context.createControl(New ul())
        page.body().addchild(ul)

        Dim li As li = Nothing
        li = context.createControl(New colorli(page))
        ul.addchild(li)
        Dim xmltext As xmltext = Nothing
        xmltext = context.createControl(New xmltext())
        xmltext.text = context.string(stringId.HOMEPAGE_VIEW)
        li.addchild(xmltext)
        addviewform(context, li)

        li = context.createControl(New colorli(page))
        ul.addchild(li)
        xmltext = context.createControl(New xmltext())
        xmltext.text = context.string(stringId.HOMEPAGE_DOWNLOAD)
        li.addchild(xmltext)
        addgetform(context, li)

        li = context.createControl(New colorli(page))
        ul.addchild(li)
        xmltext = context.createControl(New xmltext())
        xmltext.text = context.string(stringId.HOMEPAGE_UPLOAD)
        li.addchild(xmltext)
        addputform(context, li)

        Dim hostingfileCount As UInt64
        If storoom.keycount(hostingfileCount) Then
            li = context.createControl(New colorli(page))
            li.text = context.string(stringId.HOMEPAGE_HOSTINGFILE_BEFORE) + _
                      Convert.ToString(hostingfileCount) + _
                      context.string(stringId.HOMEPAGE_HOSTINGFILE_AFTER)
            ul.addchild(li)
        End If

        control = page
        Return True
    End Function
End Class
